import 'package:flutter/material.dart';
import '../../../../config/themes/app_colors.dart';

/// 天气卡片组件
class WeatherCard extends StatelessWidget {
  final String temperature;
  final String condition;
  final String humidity;
  
  const WeatherCard({
    Key? key,
    required this.temperature,
    required this.condition,
    required this.humidity,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Card(
      elevation: 2,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(12),
      ),
      child: Container(
        width: double.infinity,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(12),
          gradient: AppColors.infoGradient,
        ),
        child: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Row(
            children: [
              // 天气图标和温度
              Expanded(
                flex: 3,
                child: Row(
                  children: [
                    Icon(
                      _getWeatherIcon(condition),
                      color: Colors.white,
                      size: 40,
                    ),
                    const SizedBox(width: 16),
                    Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          temperature,
                          style: const TextStyle(
                            fontSize: 24,
                            fontWeight: FontWeight.bold,
                            color: Colors.white,
                          ),
                        ),
                        Text(
                          condition,
                          style: const TextStyle(
                            fontSize: 14,
                            color: Colors.white,
                          ),
                        ),
                      ],
                    ),
                  ],
                ),
              ),
              
              // 分隔线
              Container(
                height: 50,
                width: 1,
                color: Colors.white.withOpacity(0.3),
              ),
              
              // 湿度信息
              Expanded(
                flex: 2,
                child: Padding(
                  padding: const EdgeInsets.only(left: 16.0),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      const Text(
                        '湿度',
                        style: TextStyle(
                          fontSize: 14,
                          color: Colors.white,
                        ),
                      ),
                      const SizedBox(height: 4),
                      Row(
                        children: [
                          const Icon(
                            Icons.water_drop_outlined,
                            color: Colors.white,
                            size: 16,
                          ),
                          const SizedBox(width: 4),
                          Text(
                            humidity,
                            style: const TextStyle(
                              fontSize: 16,
                              fontWeight: FontWeight.bold,
                              color: Colors.white,
                            ),
                          ),
                        ],
                      ),
                    ],
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
  
  /// 根据天气状况获取图标
  IconData _getWeatherIcon(String condition) {
    switch (condition.toLowerCase()) {
      case '晴':
        return Icons.wb_sunny;
      case '多云':
        return Icons.cloud;
      case '阴':
        return Icons.cloud_queue;
      case '小雨':
      case '中雨':
      case '大雨':
        return Icons.grain;
      case '雷阵雨':
        return Icons.flash_on;
      case '雪':
      case '小雪':
      case '中雪':
      case '大雪':
        return Icons.ac_unit;
      case '雾':
        return Icons.cloud;
      default:
        return Icons.wb_sunny;
    }
  }
} 